/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedbean.Sales;

import entity.AccessRole;
import entity.Customer;
import entity.Employee;
import entity.Inquiry;
import entity.InquiryItem;
import entity.Lead;
import entity.Product;
import entity.Quotation;
import entity.QuotationItem;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import managedbean.UserSessionManagerBean;
import org.primefaces.event.SelectEvent;
import session.stateless.AccessRoleSessionBeanLocal;
import session.stateless.CustomerSessionBeanLocal;
import session.stateless.EmployeeSessionBeanLocal;
import session.stateless.JobSessionBeanLocal;
import session.stateless.LeadSessionBeanLocal;
import session.stateless.LogSessionBeanLocal;
import session.stateless.MessageSessionBeanLocal;
import session.stateless.ProductSessionBeanLocal;
import session.stateless.SalesInquirySessionBeanLocal;

/**
 *
 * @author Wx
 */
@ManagedBean(name = "salesInquiryManagerBean")
@RequestScoped
public class SalesInquiryManagerBean {

    @ManagedProperty(value = "#{userSessionManagerBean}")
    private UserSessionManagerBean userSessionManagerBean;
    @EJB
    AccessRoleSessionBeanLocal accessRoleSessionBeanLocal;
    @EJB
    EmployeeSessionBeanLocal employeeSessionBeanLocal;
    @EJB
    private LogSessionBeanLocal logSessionBeanLocal;
    @EJB
    SalesInquirySessionBeanLocal salesInquirySessionBeanLocal;
    @EJB
    ProductSessionBeanLocal productSessionBeanLocal;
    @EJB
    LeadSessionBeanLocal leadSessionBeanLocal;
    @EJB
    CustomerSessionBeanLocal customerSessionBeanLocal;
    @EJB
    JobSessionBeanLocal jobSessionBeanLocal;
    @EJB
    MessageSessionBeanLocal messageSessionBeanLocal;
    private String emailAddress;
    //InquiryItem
    private Product product = new Product();
    private double unitPrice;
    private int quantity;
    private double discount;
    //PageLoads
    private String loadUpdateSalesContact;
    private String loadInquiriesPage;
    private String loadInquiryPage;
    private String loadSearchSalesContacts;
    //viewInquiries.xhtml
    private List<Inquiry> inquiries;
    private int inquiriesCount;
    //inquiry.xhtml
    private Inquiry selectedInquiry;
    private List<InquiryItem> inquiryItems;
    private int inquiryItemsCount;
    private List<Product> products;
    private InquiryItem inquiryItem;

    /** Creates a new instance of SalesInquiryManagerBean */
    public SalesInquiryManagerBean() {
    }

    /**
     * @return the emailAddress
     */
    public String getEmailAddress() {
        return emailAddress;
    }

    /**
     * @param emailAddress the emailAddress to set
     */
    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }

    /**
     * @param loadUpdateSalesContact the loadUpdateSalesContact to set
     */
    public void setLoadUpdateSalesContact(String loadUpdateSalesContact) {
        this.loadUpdateSalesContact = loadUpdateSalesContact;
    }

    public void addSalesInquiry(ActionEvent event) {


        try {
            Customer customer = customerSessionBeanLocal.getCustomer(emailAddress, null);

            if (customer != null) {
                userSessionManagerBean.setCustomer(customer);

                FacesContext.getCurrentInstance().getExternalContext().redirect("http://" + getUserSessionManagerBean().getServerName() + ":"
                        + getUserSessionManagerBean().getServerPort() + "/MerlionERP-war/Web_Sales/updateCustomer.xhtml");
            } else {
                Lead lead = leadSessionBeanLocal.getLead(emailAddress);

                if (lead != null) {

                    userSessionManagerBean.setRequest("inquiries.xhtml");
                    userSessionManagerBean.setSelectedItem(lead);
                    userSessionManagerBean.setSelectedLead(lead);

                    FacesContext.getCurrentInstance().getExternalContext().redirect("http://" + getUserSessionManagerBean().getServerName() + ":"
                            + getUserSessionManagerBean().getServerPort() + "/MerlionERP-war/Web_Sales/updateLead.xhtml");
                } else {
                    lead = new Lead();
                    lead.setEmail(emailAddress);
                    userSessionManagerBean.setSelectedItem(lead);
                    userSessionManagerBean.setRequest("addSalesContact.xhtml");
                    FacesContext.getCurrentInstance().getExternalContext().redirect("http://" + getUserSessionManagerBean().getServerName() + ":"
                            + getUserSessionManagerBean().getServerPort() + "/MerlionERP-war/Web_Sales/addLead.xhtml");
                }
            }
//            SalesContact sc = salesInquirySessionBeanLocal.getSalesContact(emailAddress);
//
//            if (sc == null) { //if sales contact does not exist
//                salesInquirySessionBeanLocal.addSalesContact(emailAddress, name, phone, fax, description);
//
//                sc = salesInquirySessionBeanLocal.getSalesContact(emailAddress);
//
//                userSessionManagerBean.setSelectedSalesContact(sc);
//
//                FacesContext.getCurrentInstance().getExternalContext().redirect("http://" + getUserSessionManagerBean().getServerName() + ":"
//                        + getUserSessionManagerBean().getServerPort() + "/MerlionERP-war/inquiries.xhtml");
//            } else { //if sales contact already exists
//                FacesContext.getCurrentInstance().addMessage(null,
//                        new FacesMessage(FacesMessage.SEVERITY_ERROR, "Sales contact already exists.", ""));
//            }
        } catch (Exception ex) {
            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_ERROR, ex.toString(), ""));
        }

    }

    public void addInquiryItem(ActionEvent event) { //to add an inquiry item to an inquiry
        try {
            if (product.getCode() != null) {

                    Product p = productSessionBeanLocal.getProduct(product.getCode());
                    
                    if (quantity > 23999)
                        discount =5;    //5% for more than 100 cases
                    else if (quantity >11999)
                        discount = 3;   //3% for more than 50 cases
                    else if (quantity >2399)
                        discount = 1; //1% for more than 10 cases
                    else
                        discount = 0;
                    
                    InquiryItem ii = new InquiryItem(p.getPrice(), quantity, round(discount, 2), p);

                    salesInquirySessionBeanLocal.updateInquiry(userSessionManagerBean.getSelectedInquiry().getId(), ii); //update inquiry

                    userSessionManagerBean.setSelectedInquiry(salesInquirySessionBeanLocal. //retrieve and set updated inquiry 
                            getInquiry(userSessionManagerBean.getSelectedInquiry().getId())); //from DB

                    FacesContext.getCurrentInstance().getExternalContext().redirect("http://"
                            + userSessionManagerBean.getServerName() + ":"
                            + userSessionManagerBean.getServerPort()
                            + "/MerlionERP-war/Web_Sales/inquiry.xhtml"); //redirect to inquiry.xhtml
                 
            } else {
                FacesContext.getCurrentInstance().addMessage(null,
                        new FacesMessage(FacesMessage.SEVERITY_ERROR, "A product must be selected.", ""));
            }
        } catch (Exception ex) {
            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_ERROR, ex.toString(), ""));
        }
    }

    public double round(double valueToRound, int numberOfDecimalPlaces) {
        double multiplicationFactor = Math.pow(10, numberOfDecimalPlaces);
        double interestedInZeroDPs = valueToRound * multiplicationFactor;

        return Math.round(interestedInZeroDPs) / multiplicationFactor;
    }

    public void convertQuotation(ActionEvent e) {
        try {
            if (userSessionManagerBean.getSelectedInquiry().getInquiryItems().size() > 0) {
                Customer c = userSessionManagerBean.getCustomer();

                if (c == null) { //if the company is not a customer yet, convert him to one first
                    Lead l = userSessionManagerBean.getSelectedLead();

                    //retrieve lead with updated inquiries
                    l = leadSessionBeanLocal.getLead(l.getEmail());

                    //add lead into customer
                    //the person who converted this account to a customer will be recorded
                    customerSessionBeanLocal.addCustomer(l.getEmployee().getUserId(), l.getEmail(), l.getFirstName(), l.getLastName(), l.getCompany(),
                            l.getTitle(), "Converted", l.getPhone(), l.getCompanyAddress(), l.getRevenue(), l.getDescription(), l.getNumEmployee(), l.getIndustry(), null, "Customer", Boolean.FALSE, l.getInquiries());

                    try { //sending message to managers to notify them of new customer needed to be assigned an exective
                        ArrayList<AccessRole> rlist = accessRoleSessionBeanLocal.getAccessRoles("Assign Exec. ");
                        ArrayList<Employee> employees = employeeSessionBeanLocal.getEmployees(rlist);

                        for (Employee em : employees) {
                            Employee owner = employeeSessionBeanLocal.getEmployee("system");
                            messageSessionBeanLocal.addMessage("System", em.getUserId(), "Assignment of Customer",
                                    "Customer <b>" + l.getCompany() + "</b> has been created, please assign an executive to handle the customer. "
                                    + "<p><hr/><p>This is a system generated message, no reply is required.", owner);

                            owner = employeeSessionBeanLocal.getEmployee(em.getUserId());
                            messageSessionBeanLocal.addMessage("System", em.getUserId(), "Assignment of Customer",
                                    "Customer <b>" + l.getCompany() + "</b> has been created, please assign an executive to handle the customer. "
                                    + "<p><hr/><p>This is a system generated message, no reply is required.", owner);
                        }
                    } catch (Exception ex) { //Not employees able to assign executive to customer}
                        ex.printStackTrace();
                    }

                    //retrieve new customer
                    c = customerSessionBeanLocal.getCustomer(l.getEmail(), Boolean.FALSE);

                    //remove lead since already converted to a customer
                    leadSessionBeanLocal.deleteLead(l.getCustId());
                }

                Inquiry i = userSessionManagerBean.getSelectedInquiry();

                //update selected inquiry to Converted status
                salesInquirySessionBeanLocal.updateInquiry(i.getId(), "Converted");

                Calendar cal = Calendar.getInstance();
                Timestamp ts = new Timestamp(cal.getTime().getTime());

                //creating new quotation
                Quotation q = new Quotation();
                q.setRemark("Converted from an inquiry.");
                q.setCreationDate(ts);
                q.setInquiry(i);
                q.setStatus("Expired");

                List<QuotationItem> items = new ArrayList<QuotationItem>();
                QuotationItem qi;
                Product p = new Product();
                double unit, dis, actual, total;
                for (InquiryItem ii : i.getInquiryItems()) { //for each ii, create a qi
                    p = productSessionBeanLocal.getProduct(ii.getProduct().getCode());

                    actual = 1 - (ii.getDiscount() / 100); //discount = 5 = 0.05, actual = 1 - 0.05 = 0.95
                    total = (ii.getUnitPrice() * ii.getQuantity()) * actual; //(unitPrice * quantity) * 0.95

                    //create a new quotation item from the inquiry item
                    qi = new QuotationItem(ii.getUnitPrice(), total, ii.getQuantity(), ii.getDiscount(), p,
                            0.0, null, null, "");

                    items.add(qi); //add the qi created into a list
                }
                total = 0;
                for (QuotationItem qi2 : items) { //computing the total amount for the converted inquiry
                    total += qi2.getSubTotal();
                }
                q.setQuotationItems(items); //set the list that was just populated to the quotation
                q.setTotalAmount(total); //set the total amount for the quotation

                //create quotations
                ArrayList<Quotation> quotations = new ArrayList<Quotation>();
                quotations.add(q);

                //creating a new job
                //the person who converted this account to a customer will be recorded
                jobSessionBeanLocal.addJob(c.getCustId(), userSessionManagerBean.getUserId(), quotations, ts, null, 
                        "A new job created automatically from the conversion of an inquiry.", "Normal routine");

                //retrieve new customer and update session
                c = customerSessionBeanLocal.getCustomer(c.getEmail(), Boolean.FALSE);
                userSessionManagerBean.setCustomer(c);

                FacesContext.getCurrentInstance().getExternalContext().redirect("http://"
                        + userSessionManagerBean.getServerName() + ":"
                        + userSessionManagerBean.getServerPort()
                        + "/MerlionERP-war/Web_Sales/updateCustomer.xhtml"); //redirect to updateCustomer.xhtml
            } else {
                FacesContext.getCurrentInstance().addMessage(null,
                        new FacesMessage(FacesMessage.SEVERITY_ERROR, "Number of inquiry item cannot be 0.", ""));
            }
        } catch (Exception ex) {
            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_ERROR, ex.toString(), ""));
        }
    }

    public void delete(ActionEvent e) {  //to delete an inquiry item
        try {
            if (inquiryItem != null) {
                salesInquirySessionBeanLocal.deleteInquiryItem(userSessionManagerBean.getSelectedInquiry().getId(), inquiryItem.getId());

                userSessionManagerBean.setSelectedInquiry(
                        salesInquirySessionBeanLocal.getInquiry(userSessionManagerBean.getSelectedInquiry().getId()));

                FacesContext.getCurrentInstance().getExternalContext().redirect("http://"
                        + getUserSessionManagerBean().getServerName() + ":"
                        + getUserSessionManagerBean().getServerPort()
                        + "/MerlionERP-war/Web_Sales/inquiry.xhtml"); //redirect to inquiry.xhtml
            } else {
                FacesContext.getCurrentInstance().addMessage(null,
                        new FacesMessage(FacesMessage.SEVERITY_ERROR, "Please select an inquiry item to delete.", ""));
            }
        } catch (Exception ex) {
            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_ERROR, ex.toString(), ""));
        }
    }

//    public void saveList(ActionEvent e) {
//        try {
//            salesInquirySessionBeanLocal.updateInquiryItems(inquiryItems);
//
//            userSessionManagerBean.setSelectedInquiry(
//                    salesInquirySessionBeanLocal.getInquiry(userSessionManagerBean.getSelectedInquiry().getId()));
//
//            FacesContext.getCurrentInstance().getExternalContext().redirect("http://"
//                    + userSessionManagerBean.getServerName() + ":"
//                    + userSessionManagerBean.getServerPort()
//                    + "/MerlionERP-war/inquiry.xhtml"); //redirect to inquiry.xhtml
//        } catch (Exception ex) {
//            FacesContext.getCurrentInstance().addMessage(null,
//                    new FacesMessage(FacesMessage.SEVERITY_ERROR, ex.toString(), ""));
//        }
//    }
    public void done(ActionEvent event) {
        try {
            if (event.getComponent().getId().equals("btnGoBackToUpdateX")) {
                if (userSessionManagerBean.isViewCustomerInquiries()) {
                    FacesContext.getCurrentInstance().getExternalContext().redirect("http://" + getUserSessionManagerBean().getServerName() + ":"
                            + getUserSessionManagerBean().getServerPort() + "/MerlionERP-war/Web_Sales/updateCustomer.xhtml");
                } else {
                    userSessionManagerBean.setSelectedItem(userSessionManagerBean.getSelectedLead());

                    FacesContext.getCurrentInstance().getExternalContext().redirect("http://" + getUserSessionManagerBean().getServerName() + ":"
                            + getUserSessionManagerBean().getServerPort() + "/MerlionERP-war/Web_Sales/updateLead.xhtml");
                }
            } else {
                FacesContext.getCurrentInstance().getExternalContext().redirect("http://" + getUserSessionManagerBean().getServerName() + ":"
                        + getUserSessionManagerBean().getServerPort() + "/MerlionERP-war/Web_Sales/inquiries.xhtml");
            }
        } catch (Exception ex) {
            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_ERROR, ex.toString(), ""));
        }
    }

//    public void doneUpdate(ActionEvent event) {
//        try {
//            salesInquirySessionBeanLocal.updateSalesContact(emailAddress, name, phone, fax, description);
//
//            userSessionManagerBean.setSelectedSalesContact("");
//
//            FacesContext.getCurrentInstance().getExternalContext().redirect("http://" + getUserSessionManagerBean().getServerName() + ":"
//                    + getUserSessionManagerBean().getServerPort() + "/MerlionERP-war/searchSalesContacts.xhtml");
//        } catch (Exception ex) {
//            FacesContext.getCurrentInstance().addMessage(null,
//                    new FacesMessage(FacesMessage.SEVERITY_ERROR, ex.toString(), ""));
//        }
//    }
    public void viewInquiries(ActionEvent event) { //to view inquiries
        try {
            String id = event.getComponent().getId();

            if (id.equals("btnViewCustomerInquiries")) {
                userSessionManagerBean.setViewCustomerInquiries(true);

                //userSessionManagerBean.setCustomer(userSessionManagerBean.getCustomer());
            } else {
                userSessionManagerBean.setViewCustomerInquiries(false);

                //userSessionManagerBean.setSelectedLead(userSessionManagerBean.getSelectedLead());
            }

            FacesContext.getCurrentInstance().getExternalContext().redirect("http://" + getUserSessionManagerBean().getServerName() + ":"
                    + getUserSessionManagerBean().getServerPort() + "/MerlionERP-war/Web_Sales/inquiries.xhtml");
        } catch (Exception ex) {
            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_ERROR, ex.toString(), ""));
        }
    }

    public void onRowSelect(SelectEvent event) { //on row select of inquiries datatable in inquiries.xhtml
        try {
            String id = event.getComponent().getId();

            userSessionManagerBean.setSelectedInquiry(selectedInquiry);

            FacesContext.getCurrentInstance().getExternalContext().redirect("http://"
                    + userSessionManagerBean.getServerName() + ":"
                    + userSessionManagerBean.getServerPort()
                    + "/MerlionERP-war/Web_Sales/inquiry.xhtml"); //redirect to inquiry.xhtml on message select

        } catch (Exception ex) {
            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_ERROR, ex.toString(), ""));
        }
    }

    public void addInquiry(ActionEvent event) {
        try {
            Calendar cal = Calendar.getInstance();
            Timestamp ts = new Timestamp(cal.getTime().getTime());

            selectedInquiry = new Inquiry(ts);
            userSessionManagerBean.setSelectedInquiry(selectedInquiry);

            if (userSessionManagerBean.isViewCustomerInquiries()) {
                salesInquirySessionBeanLocal.updateCustomer(userSessionManagerBean.getCustomer().getCustId(), selectedInquiry);
                userSessionManagerBean.setCustomer(customerSessionBeanLocal.getCustomer(userSessionManagerBean.getCustomer().getCustId()));
                logSessionBeanLocal.addLog("Add sales inquiry", "Sales inquiry created: " + selectedInquiry.getId() + " for sales lead: " + userSessionManagerBean.getCustomer().getCompany(), "updateCustomer.xhtml", userSessionManagerBean.getUserId());
            } else {
                salesInquirySessionBeanLocal.updateLead(userSessionManagerBean.getSelectedLead().getCustId(), selectedInquiry);
                userSessionManagerBean.setSelectedLead(leadSessionBeanLocal.getLead(userSessionManagerBean.getSelectedLead().getEmail()));
                logSessionBeanLocal.addLog("Add sales inquiry", "Sales inquiry created: " + selectedInquiry.getId() + " for customer: " + userSessionManagerBean.getSelectedLead().getCompany(), "updateLead.xhtml", userSessionManagerBean.getUserId());

            }

            FacesContext.getCurrentInstance().getExternalContext().redirect("http://"
                    + userSessionManagerBean.getServerName() + ":"
                    + userSessionManagerBean.getServerPort()
                    + "/MerlionERP-war/Web_Sales/inquiry.xhtml"); //redirect to inquiry.xhtml
        } catch (Exception ex) {
            ex.printStackTrace();
            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_ERROR, ex.toString(), ""));
        }
    }

    /**
     * @return the userSessionManagerBean
     */
    public UserSessionManagerBean getUserSessionManagerBean() {
        return userSessionManagerBean;
    }

    /**
     * @param userSessionManagerBean the userSessionManagerBean to set
     */
    public void setUserSessionManagerBean(UserSessionManagerBean userSessionManagerBean) {
        this.userSessionManagerBean = userSessionManagerBean;
    }

    /**
     * @return the loadInquiriesPage
     */
    public String getLoadInquiriesPage() {
        if (userSessionManagerBean.isViewCustomerInquiries()) {
            if (userSessionManagerBean.getCustomer() != null) {
                userSessionManagerBean.setCustomer(customerSessionBeanLocal.getCustomer(userSessionManagerBean.getCustomer().getEmail(), Boolean.FALSE));

                List<Inquiry> temp = new ArrayList<Inquiry>();

                for (Inquiry i : userSessionManagerBean.getCustomer().getInquiries()) {
                    if (i.getStatus().equals("Pending")) {
                        temp.add(i);
                    }
                }

                setInquiries(temp);

                this.setInquiriesCount(inquiries.size());
            }
        } else {
            if (userSessionManagerBean.getSelectedLead() != null) {
                userSessionManagerBean.setSelectedLead(leadSessionBeanLocal.getLead(userSessionManagerBean.getSelectedLead().getEmail()));

                setInquiries(userSessionManagerBean.getSelectedLead().getInquiries());

                this.setInquiriesCount(inquiries.size());
            }
        }

        return null;
    }

    /**
     * @param loadInquiriesPage the loadInquiriesPage to set
     */
    public void setLoadInquiriesPage(String loadInquiriesPage) {
        this.loadInquiriesPage = loadInquiriesPage;
    }

    /**
     * @return the inquiries
     */
    public List<Inquiry> getInquiries() {
        return inquiries;
    }

    /**
     * @param inquiries the inquiries to set
     */
    public void setInquiries(List<Inquiry> inquiries) {
        this.inquiries = inquiries;
    }

    /**
     * @return the count
     */
    public int getInquiriesCount() {
        return inquiriesCount;
    }

    /**
     * @param count the count to set
     */
    public void setInquiriesCount(int inquiriesCount) {
        this.inquiriesCount = inquiriesCount;
    }

    /**
     * @return the selectedInquiry
     */
    public Inquiry getSelectedInquiry() {
        return selectedInquiry;
    }

    /**
     * @param selectedInquiry the selectedInquiry to set
     */
    public void setSelectedInquiry(Inquiry selectedInquiry) {
        this.selectedInquiry = selectedInquiry;
    }

    /**
     * @return the loadInquiryPage
     */
    public String getLoadInquiryPage() {
        products = productSessionBeanLocal.getProducts();

        if (userSessionManagerBean.getSelectedInquiry() != null) {
            setInquiryItems(userSessionManagerBean.getSelectedInquiry().getInquiryItems());

            this.setInquiryItemsCount(inquiryItems.size());
        }

        return null;
    }

    /**
     * @param loadInquiryPage the loadInquiryPage to set
     */
    public void setLoadInquiryPage(String loadInquiryPage) {
        this.loadInquiryPage = loadInquiryPage;
    }

    /**
     * @return the inquiryItemsCount
     */
    public int getInquiryItemsCount() {
        return inquiryItemsCount;
    }

    /**
     * @param inquiryItemsCount the inquiryItemsCount to set
     */
    public void setInquiryItemsCount(int inquiryItemsCount) {
        this.inquiryItemsCount = inquiryItemsCount;
    }

    /**
     * @return the inquiryItems
     */
    public List<InquiryItem> getInquiryItems() {
        return inquiryItems;
    }

    /**
     * @param inquiryItems the inquiryItems to set
     */
    public void setInquiryItems(List<InquiryItem> inquiryItems) {
        this.inquiryItems = inquiryItems;
    }

    /**
     * @return the products
     */
    public List<Product> getProducts() {
        return products;
    }

    /**
     * @param products the products to set
     */
    public void setProducts(List<Product> products) {
        this.products = products;
    }

    /**
     * @return the product
     */
    public Product getProduct() {
        return product;
    }

    /**
     * @param product the product to set
     */
    public void setProduct(Product product) {
        this.product = product;
    }

    /**
     * @return the unitPrice
     */
    public double getUnitPrice() {
        return unitPrice;
    }

    /**
     * @param unitPrice the unitPrice to set
     */
    public void setUnitPrice(double unitPrice) {
        this.unitPrice = unitPrice;
    }

    /**
     * @return the quantity
     */
    public int getQuantity() {
        return quantity;
    }

    /**
     * @param quantity the quantity to set
     */
    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    /**
     * @return the discount
     */
    public double getDiscount() {
        return discount;
    }

    /**
     * @param discount the discount to set
     */
    public void setDiscount(double discount) {
        this.discount = discount;
    }

    /**
     * @return the inquiryItem
     */
    public InquiryItem getInquiryItem() {
        return inquiryItem;
    }

    /**
     * @param inquiryItem the inquiryItem to set
     */
    public void setInquiryItem(InquiryItem inquiryItem) {
        this.inquiryItem = inquiryItem;
    }
}
